package com.javasm.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.javasm.common.page.PageResult;
import com.javasm.domin.criteria.AftersaleEnterDepotDetailCriteria;
import com.javasm.domin.entity.AftersaleEnterDepotDetail;
import com.javasm.domin.vo.AftersaleEnterDepotDetailVo;
import com.javasm.mapper.AftersaleEnterDepotDetailMapper;
import com.javasm.service.AftersaleEnterDepotDetailService;
import com.javasm.service.base.impl.BaseServiceimpl;
import com.javasm.transfer.AftersaleEnterDepotDetailTransfer;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author：longjinyi
 * @Version：1.0
 * @Date：2022/1/20-17:46
 * @Since:jdk1.8
 * @Description:
 */
@Service
@Transactional
@RequiredArgsConstructor
public class AftersaleEnterDepotDetailServiceImpl extends BaseServiceimpl<AftersaleEnterDepotDetail> implements AftersaleEnterDepotDetailService {

    private final AftersaleEnterDepotDetailMapper aftersaleEnterDepotDetailMapper;

    private final AftersaleEnterDepotDetailTransfer aftersaleEnterDepotDetailTransfer;

    @Override
    public PageResult<AftersaleEnterDepotDetailVo> selectByPage(AftersaleEnterDepotDetailCriteria aftersaleEnterDepotDetailCriteria) {

        PageHelper.startPage(aftersaleEnterDepotDetailCriteria.getCurrentPage(), aftersaleEnterDepotDetailCriteria.getPageSize());
        LambdaQueryWrapper<AftersaleEnterDepotDetail> lambda = new QueryWrapper<AftersaleEnterDepotDetail>().lambda();

        List<AftersaleEnterDepotDetail> aftersaleEnterDepotDetails = aftersaleEnterDepotDetailMapper.list(lambda);

        PageInfo<AftersaleEnterDepotDetail> pageInfo = new PageInfo<>(aftersaleEnterDepotDetails);
        List<AftersaleEnterDepotDetailVo> aftersaleEnterDepotDetailVos = aftersaleEnterDepotDetailTransfer.toVO(aftersaleEnterDepotDetails);

        return new PageResult<AftersaleEnterDepotDetailVo>(pageInfo.getTotal(), aftersaleEnterDepotDetailVos);
    }
}
